package com.wuming.caiwu.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.*;


/***********************************************
 * 配置档范例
 * # ============ redis conf start ==============
 * <p/>
 * #连接池的最大数据库连接数。设为0表示无限制。
 * redis.pool.maxActive=20
 * <p/>
 * #最大空闲数，数据库连接的最大空闲时间。超过空闲时间，数据库连接将被标记为不可用，然后被释放。
 * redis.pool.maxIdle=3
 * <p/>
 * #最大等待毫秒数,单位为 ms,超过时间会出错误信息
 * redis.pool.maxWaitTime=3000
 * <p/>
 * #读取超时时间
 * redis.pool.timeout=5000
 * <p/>
 * #服务器地址
 * redis.host=192.168.112.199
 * <p/>
 * #端口号
 * redis.port=6379
 * <p/>
 * #数据库下标 0~15
 * redis.dbIndex=0
 * <p/>
 * #口令
 * redis.auth=xxxxx
 * <p/>
 * # ============  redis conf end  ==============
 ***********************************************/

/*******************************************************************************
 * Redis客户端工具类
 *
 * @author freeman983
 */
public class RedisUtil {

    private static Logger logger = LoggerFactory.getLogger(RedisUtil.class);
    private static JedisPool jp = null;
    public static String OK = "OK";

//	private static RedisUtil redisUtil = new RedisUtil();

    // 默认读取超时时间
    private static int DEFAULT_TIMEOUT = 3 * 1000;// 10秒

    // 连接池的最大数据库连接数。设为0表示无限制。
    private static int DEFAULT_MAXACTIVE = 100;

    // 最大空闲数，数据库连接的最大空闲时间。超过空闲时间，数据库连接将被标记为不可用，然后被释放。设为0表示无限制。
    private static int DEFAULT_MAXIDLE = 30;

    private static int DEFAULT_MINIDLE = 1;

    // 最大等待毫秒数, 单位为 ms, 超过时间会出错误信息
    private static long DEFAULT_MAXWAITTIME = 5000;

    // 默认的数据库 0~15
//	private static int DEFAULT_DBINDEX = 0;

    private static boolean DEFAULT_TESTONRETURN = true;
    private static boolean DEFAULT_TESTONBORROW = false;
    private static boolean DEFAULT_TESTWHILEIDLE = true;
    private static int DEFAULT_NUMTESTSPEREVICTIONRUN = -1;
    private static int DEFAULT_MINEVICTABLEIDLETIMEMILLIS = 60000;
    private static int DEFAULT_TIMEBETWEENEVICTIONRUNSMILLIS = 30000;

    private static String REDIS_POOL_MAXACTIVE = "";
    private static String REDIS_POOL_MAXIDLE = "";
    private static String REDIS_POOL_MAXWAITTIME = "";
    private static String REDIS_POOL_TIMEOUT = "";
    //	private static String REDIS_HOST = "192.168.112.14";
    private static String REDIS_HOST = "";
    private static String REDIS_PORT = "";
    private static String REDIS_DBINDEX = "0";
    private static String REDIS_AUTH = "";

    static {
        Properties properties = PropertyUtil.loadProperties("redis.properties");
        REDIS_HOST = properties.getProperty("redis.host");
        REDIS_PORT = properties.getProperty("redis.port");
        REDIS_POOL_TIMEOUT = properties.getProperty("redis.timeout");
        REDIS_POOL_MAXIDLE = properties.getProperty("redis.maxIdle");
        REDIS_POOL_MAXACTIVE = properties.getProperty("redis.maxTotal");
        REDIS_POOL_MAXWAITTIME = properties.getProperty("redis.maxWaitMillis");
        jp = getJedisPool();
    }

    /******************************
     * 直接返回jedis客户端实例，不使用连接池，客户端需要自己释放
     *
     * @return
     */
    public static Jedis getJedisClient() {
        String host = REDIS_HOST;
        int port = Integer.valueOf(REDIS_PORT);
        int dbindex = 0;

        // // 使用密码连接
//		if (ConstantsPropertyUtil.getConstantsValue(REDIS_AUTH) != null
//                && !ConstantsPropertyUtil.getConstantsValue(REDIS_AUTH).equals(
//                        "")) {
//            ConstantsPropertyUtil.getConstantsValue(REDIS_AUTH);
//        }

        if (REDIS_DBINDEX != null) {
            dbindex = Integer.valueOf(REDIS_DBINDEX);
        }
        Jedis jedis = new Jedis(host, port);
        jedis.select(dbindex);

        return jedis;
    }

    /***************************************************************************
     * 检验key是否存在
     *
     * @param key
     * @return
     */
    public static boolean existsKey(String key) {
        boolean r = false;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            r = jd.exists(key);

        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
            throw new RuntimeException("Redis error:" + e.getMessage());
        } finally {
            release(jd);
        }
        return r;
    }

    /***************************************************************************
     * 删除缓存
     *
     * @param key
     * @return
     */
    public static boolean del(String key) {
        long r = 0;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            r = jd.del(key);

        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
            throw new RuntimeException("Redis error:" + e.getMessage());
        } finally {
            release(jd);
        }
        return (0 == r ? false : true);
    }

    /***************************************************************************
     * 写入缓存
     *
     * @param key
     * @return
     */
    public static boolean set(String key, String value) {
        return set(key, value, -1);
    }

    /***************************************************************************
     * 写入缓存，可以设定超时时间（秒）
     *
     * @param key
     * @param value
     * @param timeout
     * @return
     */
    public static boolean set(String key, String value, int timeout) {
        String r = "";
        Jedis jd = null;
        try {

            jd = getRedisClient();
            r = jd.set((key), value);

            if (timeout != -1) {
                // 设置失效时间，不设置为永久保存
                getRedisClient().expire((key), timeout);
            }
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
            throw new RuntimeException("set 失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
        return (OK.equals(r) ? true : false);
    }

    /***************************************************************************
     * 读取缓存
     *
     * @param key
     * @return
     */
    public static String get(String key) {
        String s = null;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            s = jd.get((key));

        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
            throw new RuntimeException("get 失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
        return s;
    }

    /***************************************************************************
     * 获取jedis连接池
     *
     * @return
     */
    public static synchronized JedisPool getJedisPool() {
        if (jp == null) {
            JedisPoolConfig config = new JedisPoolConfig();

            int maxActive = DEFAULT_MAXACTIVE;
            int maxidle = DEFAULT_MAXIDLE;
            long maxwaittime = DEFAULT_MAXWAITTIME;
            int timeout = DEFAULT_TIMEOUT;
            String auth = null;

            if (REDIS_POOL_MAXACTIVE != null) {
                maxActive = Integer.valueOf(REDIS_POOL_MAXACTIVE);
            }

            if (REDIS_POOL_MAXIDLE != null) {
                maxidle = Integer.valueOf(REDIS_POOL_MAXIDLE);
            }

            if (REDIS_POOL_MAXWAITTIME != null) {
                maxwaittime = Long.valueOf(REDIS_POOL_MAXWAITTIME);
            }

            if (REDIS_POOL_TIMEOUT != null) {
                timeout = Integer.valueOf(REDIS_POOL_TIMEOUT);
            }

            String host = REDIS_HOST;
            int port = Integer.valueOf(REDIS_PORT);

            // // 使用密码连接
            if (REDIS_AUTH != null
                    && !REDIS_AUTH
                    .equals("")) {
                auth = REDIS_AUTH;
            }

//            if (ConstantsPropertyUtil.getConstantsValue(REDIS_DBINDEX) != null) {
//                Integer.valueOf(ConstantsPropertyUtil
//                        .getConstantsValue(REDIS_DBINDEX));
//			}
            config.setMaxActive(maxActive);
            config.setMaxIdle(maxidle);
            config.setMinIdle(DEFAULT_MINIDLE);
            config.setMaxWait(maxwaittime);
            config.setTestOnReturn(DEFAULT_TESTONRETURN);
            config.setTestOnBorrow(DEFAULT_TESTONBORROW);
            config.setTestWhileIdle(DEFAULT_TESTWHILEIDLE);

            config.setNumTestsPerEvictionRun(DEFAULT_NUMTESTSPEREVICTIONRUN);
            config.setMinEvictableIdleTimeMillis(DEFAULT_MINEVICTABLEIDLETIMEMILLIS);
            config.setTimeBetweenEvictionRunsMillis(DEFAULT_TIMEBETWEENEVICTIONRUNSMILLIS);

            logger.info("JedisPool init ... maxActive:" + maxActive
                    + "  maxidle:" + maxidle + "  maxwaittime:" + maxwaittime);
            System.out.println("JedisPool init ...host:" + host + "  port:"
                    + port + "  maxActive:" + maxActive + "  maxidle:"
                    + maxidle + "  maxwaittime:" + maxwaittime + "  timeout:"
                    + timeout);
            // jp = new JedisPool(config, host, port, timeout, auth, dbindex);
            // //2.1
            // 兼容2.00
            jp = new JedisPool(config, host, port, timeout, auth); // 2.0

            logger.info("JedisPool init success！！！");

        }
        return jp;
    }

    /***************************************************************************
     * 重置JedisPool
     */
    public static void jedisPoolReset() {
        try {
            if (jp != null)
                jp.destroy();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("重置jedis连接池出错，原因是：" + e.getMessage());
        }
        getJedisPool();
    }

    /***************************************************************************
     * 重置JedisPool
     */
    public static void destroy() {
        try {
            if (jp != null) {
                jp.destroy();
                logger.info("redis pool destroy!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***************************************************************************
     * 获取jedis客户端实例
     *
     * @return
     */
    private static Jedis getRedisClient() {
        return getJedisPool().getResource();
    }

    /***************************************************************************
     * 获取队列大小
     *
     * @param key
     */
    public static long getStackSize(String key) {
        long r = 0;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            r = jd.llen(key);
            // System.out.println("lpush ret:"+r);
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
            logger.error("getStackSize 出错，原因是:" + e.getMessage());
            throw new RuntimeException("getStackSize 失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }

        return r;
    }

    /***************************************************************************
     * 队列写入
     *
     * @param key
     */
    public static boolean pushStack(String key, String value) {
        Jedis jd = null;
        long r = 0;
        try {
            jd = getRedisClient();
            r = jd.lpush(key, value);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("push 出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
            throw new RuntimeException("push 失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }

        return (r > 0 ? true : false);
    }

    /***************************************************************************
     * 队列出栈
     *
     * @param key
     */
    public static String popStack(String key) {
        String s = null;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            s = jd.rpop(key);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("pop 出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
            throw new RuntimeException("pop 失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
        return s;
    }

    /***************************************************************************
     * 写入map
     *
     * @param key
     * @param map
     */
    public static void setMap(String key, Map<String, String> map) {
        setMap(key, map, -1);
    }

    /***************************************************************************
     * 写入map,并设定超时时间
     *
     * @param key
     * @param map
     */
    public static void setMap(String key, Map<String, String> map, int timeout) {
        Jedis jd = null;
        try {
            if (map != null && !map.isEmpty()) {
                jd = getRedisClient();
                for (Map.Entry<String, String> entry : map.entrySet()) {
                    jd.hset(key, entry.getKey(), entry.getValue());
                }

                if (timeout != -1) {
                    jd.expire(key, timeout);
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("setMap出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
            throw new RuntimeException("写入失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
    }

    /***************************************************************************
     * 写入set
     *
     * @param key 键
     * @param set set集合
     */
    public static void sAdd(String key, Set<String> set) {
        sAdd(key, set, -1);
    }

    /***************************************************************************
     * 写入单个值
     *
     * @param key   键
     * @param value 值
     */
    public static void sAdd(String key, String value) {
        sAdd(key, value, -1);
    }

    /***************************************************************************
     * 写入不定多个值
     *
     * @param key    键
     * @param values 值
     */
    public static void sAdd(String key, String... values) {
        sAdd(key, -1, values);
    }

    /***************************************************************************
     * 写入不定多个值,并设定超时时间
     *
     * @param key     键
     * @param values  多个值
     * @param timeout 超时时间
     * @return
     */
    public static void sAdd(String key, int timeout, String... values) {
        Jedis jd = null;
        try {
            jd = getRedisClient();
            for (String value : values)
                jd.sadd(key, value);
            if (timeout != -1) {
                jd.expire(key, timeout);
            }

        } catch (Exception e) {
            e.printStackTrace();
            logger.error("sAdd出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
            throw new RuntimeException("写入失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
    }

    /***************************************************************************
     * 写入set,并设定超时时间
     *
     * @param key     键
     * @param set     值的集合
     * @param timeout 超时时间
     * @return
     */
    public static void sAdd(String key, Set<String> set, int timeout) {
        Jedis jd = null;
        try {
            if (set != null && !set.isEmpty()) {
                jd = getRedisClient();
                for (String value : set)
                    jd.sadd(key, value);
                if (timeout != -1) {
                    jd.expire(key, timeout);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("sAdd出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
            throw new RuntimeException("写入失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
    }

    /***************************************************************************
     * 写入单个值,并设定超时时间
     *
     * @param key     键
     * @param value   值
     * @param timeout 超时时间
     * @return
     */
    public static void sAdd(String key, String value, int timeout) {
        Jedis jd = null;
        try {
            jd = getRedisClient();
            jd.sadd(key, value);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("sAdd出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
            throw new RuntimeException("写入失败，原因是:" + e.getMessage());
        } finally {
            release(jd);
        }
    }

    /***************************************************************************
     * 读取set
     *
     * @param key 键
     * @return Set<String> 值集合
     */
    public static Set<String> sMembers(String key) {
        Set<String> set = new HashSet<String>();
        Jedis jd = null;
        try {
            jd = getRedisClient();
            set = jd.smembers(key);
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return set;
    }

    /***************************************************************************
     * 移除指定键中的指定值
     *
     * @param key   键
     * @param value 指定的值
     * @return boolean
     */
    public static boolean sRem(String key, String value) {
        boolean b = false;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            jd.srem(key, value);
            b = true;
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return b;
    }

    /***************************************************************************
     * 判断指定值是否在指定键中存在
     *
     * @param key   键
     * @param value 指定的值
     * @return boolean
     */
    public static boolean sIsMember(String key, String value) {
        boolean b = false;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            b = jd.sismember(key, value);
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return b;
    }

    /***************************************************************************
     * 读取map
     *
     * @param key
     * @return
     */
    public static Map<String, String> getMap(String key) {
        Map<String, String> map = new HashMap<String, String>();
        Jedis jd = null;
        try {
            jd = getRedisClient();
            map = jd.hgetAll(key);
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return map;
    }

    /***************************************************************************
     * Map中是否包含相应的key
     *
     * @param key
     * @return
     */
    public static boolean containsKeyInMap(String key, String keyInMap) {
        boolean r = false;
        Jedis jd = null;
        try {
            jd = getRedisClient();
            r = jd.hexists(key, keyInMap);
        } catch (Exception e) {
            e.printStackTrace();
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return r;
    }

    /***************************************************************************
     * 获取Map中所有的key的集合
     *
     * @param key
     */
    public static Set<String> getKeysInMap(String key) {
        Jedis jd = null;
        Set<String> keySet = new HashSet<String>();
        try {

            jd = getRedisClient();
            keySet = jd.hkeys(key);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("getKeysInMap出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return keySet;
    }

    /***************************************************************************
     * 根据key删除map中的对应元素
     *
     * @param key
     */
    public static Set<String> delkeyInMap(String key) {
        Jedis jd = null;
        Set<String> keySet = new HashSet<String>();
        try {
            jd = getRedisClient();
            keySet = jd.hkeys(key);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("getKeysInMap出错，原因是:" + e.getMessage());
            jp.returnBrokenResource(jd);
        } finally {
            release(jd);
        }
        return keySet;
    }

    /***************************************************************************
     * 回收资源
     */
    public static void release(Jedis jd) {
        try {
            if (jp != null && jd != null) {
                jp.returnResource(jd);
                // jp.returnBrokenResource(jd);
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage(), e);
        }
    }

    /***************************************************************************
     * 回收资源
     */
    public static void destroy(Jedis jd) {
        try {
            if (jp != null && jd != null) {
                jd.select(0);
                jp.returnBrokenResource(jd);
            }

        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage(), e);
        }
    }

    /***************************************************************************
     * 关闭连接池
     */
    public void closeJedisPool() {
        if (jp != null) {
            try {
                jp.destroy();
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    /**
     * 测试
     *
     * @param args
     * @throws InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {

        // TODO Auto-generated method stub
        Jedis jedis = RedisUtil.getRedisClient();
        System.out.println(jedis.set("foo", "bar"));
//        List l = new ArrayList();
//        l.add("haha");
//        jedis.expire("foo", 30);// 30秒过期
//        String value = jedis.get("foo");
//        System.out.println(value);
//
//		// jedis.lpush("list", "a" + new Date());
//		// jedis.lpush("list", "b" + new Date());
//		// jedis.lpush("list", "c" + new Date());
//		// jedis.lpush("list", "d" + new Date());
//		//
//		// List list = jedis.lrange("list", 0, -1);
//		// for (int i = 0; i < list.size(); i++) {
//		// System.out.println(list.get(i));
//		// }
//		//
//		// String v=null;
//		//
//		// //出栈，先进先出
//		// while((v=jedis.rpop("list"))!=null){
//		// System.out.println("||||:"+v);
//		// }
//
//		jedis.hset("website", "google", "www.google.cn");
//		jedis.hset("website", "baidu", "www.baidu.com");
//		jedis.hset("website", "sina", "www.sina.com");
//
//		Map map = jedis.hgetAll("website");
//		Iterator t = map.keySet().iterator();
//		while (t.hasNext()) {
//			Object obj1 = t.next();
//			System.out.println("website:" + obj1 + ":" + map.get(obj1));
//		}
//
//		jedis.sadd("testSet", "s1");
//		jedis.sadd("testSet", "s2");
//		jedis.sadd("testSet", "s3");
//		jedis.sadd("testSet", "s4");
//		jedis.sadd("testSet", "s5");
//
//		// SREM key member移除集合中的member元素。
//		jedis.srem("testSet", "s5");
//
//		// SMEMBERS key返回集合key中的所有成员。
//		Set set = jedis.smembers("testSet");
//		Iterator t1 = set.iterator();
//		while (t1.hasNext()) {
//			Object obj1 = t1.next();
//			System.out.println(obj1);
//		}
//		//
//		// //开启事务
//		Transaction tran = null;
//
//		try {
//			tran = jedis.multi();
//
//			tran.set("name1", "freeman983");
//
//			tran.exec();// commit
//
//		} catch (Exception e) {
//			e.printStackTrace();
//			if (tran != null)
//				tran.discard();// rollback
//		}
//
//		System.out.println("n2:" + jedis.get("name1"));
//
//		RedisUtil.release(jedis);
//------------------------------------------------------------
        /*String key="a";
        RedisUtil.del(key);
		RedisUtil.sAdd(key, "a1");
		Set<String> set1=new HashSet<String>();
		set1.add("a2");set1.add("a3");
		RedisUtil.sAdd(key, set1);
		Set<String> set2=RedisUtil.sMembers(key);
		Iterator<String> itr=set2.iterator();
		while(itr.hasNext()){
			System.out.println(itr.next());
		}
		boolean b1=RedisUtil.sIsMember(key, "a2");
		System.out.println("b1:"+b1);
		RedisUtil.sRem(key, "a2");
		Set<String> set3=RedisUtil.sMembers(key);
		Iterator<String> itr1=set3.iterator();
		while(itr1.hasNext()){
			System.out.println(itr1.next());
		}
		boolean b2=RedisUtil.sIsMember(key, "a2");
		System.out.println("b2:"+b2);
		RedisUtil.sAdd(key, "a1");
		Set<String> set4=RedisUtil.sMembers(key);
		Iterator<String> itr2=set4.iterator();
		while(itr2.hasNext()){
			System.out.println(itr2.next());
		}
		System.out.println("---------------------------------");
		RedisUtil.sAdd(key, "a1","a2","a4");
		Set<String> set5=RedisUtil.sMembers(key);
		Iterator<String> itr3=set5.iterator();
		while(itr3.hasNext()){
			System.out.println(itr3.next());
		}
		boolean b3=RedisUtil.sIsMember(key, "a5");
		System.out.println("b3:"+b3);
		RedisUtil.del(key);
	*/
        System.out.println("================================区域：");
        String usercode = "A354837";
        String cardid = "8005600";
        String keyA = usercode.concat("_CONF_BUYAREA_").concat(cardid);
        Set<String> setarea = RedisUtil.sMembers(keyA);
        System.out.println(setarea.size());
        Iterator<String> itra = setarea.iterator();
        while (itra.hasNext()) {
            System.out.println(itra.next());
        }
        /*System.out.println("=======================商品屏蔽");
         String bossid="A745392";
		 String keyc=bossid.concat("_FILTER_ITEM_").concat("A745398");
		 Set<String> setc=RedisUtil.sMembers(keyc);
		 System.out.println(setc.size());
		 Iterator<String> itr1=setc.iterator();
		while(itr1.hasNext()){
			System.out.println(itr1.next());
		}
		 boolean flag1=RedisUtil.sIsMember(keyc, "8018600");
		 System.out.println(flag1);
		 
		System.out.println("=======================品牌1：");
		String userid="A683456";
		String key=bossid.concat("_CONF_UCB_").concat(userid);
		Set<String> set1=RedisUtil.sMembers(key);
		System.out.println(set1.size());
		Iterator<String> itrb1=set1.iterator();
		while(itrb1.hasNext()){
			System.out.println(itrb1.next());
		}
		System.out.println("=========================品牌2");
		String key1=bossid.concat("_CONF_CBU_").concat("c2805_").concat("v3817");
		Set<String> set2=RedisUtil.sMembers(key1);
		System.out.println(set2.size());
		Iterator<String> itrb2=set2.iterator();
		while(itrb2.hasNext()){
			System.out.println(itrb2.next());
		}
		*/
    }

}
